<script src="../addons/tim_welfare/template/mobile/js/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="../addons/tim_welfare/template/mobile/js/layer_pc/layer.js" type="text/javascript"></script>
{template 'common/header'}
<div class='container' style='padding:0 5px 10px;margin:0;width:100%'>
	<ul class="nav nav-tabs">
	  	<li {if $op == 'post'}class="active"{/if}><a href="{php echo $this->createWebUrl('phb', array('op' => 'post'));}">添加用户</a></li>
	  	<li {if $op == 'display'}class="active"{/if}><a href="{php echo $this->createWebUrl('phb',array('op'=>'display'));}">用户列表</a></li>
		{if $op == 'see'}
			<li class="active"><a href="javascript:;">捐款明细</a></li>
		{/if}
	</ul>
	{if $op == 'post'}
	<div class="panel panel-success">
	    <div class="panel-heading">常用工具 > 添加用户</div>
	</div>
	<div class="main">
		<form action="" method="post" class="form-horizontal form">
			<div class="panel panel-default">	
				<div class="panel-body">
					<div class="form-group">
						<label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">姓名</label>
						<div class="col-sm-8">
							<input type="text" name="mem_name" class="form-control" value="" />
							<span class="help-block"></span>
						</div>
					</div>	
					<div class="form-group">
						<label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">头像</label>
						<div class="col-sm-8">
							{php echo tpl_form_field_image('mem_photo',$item['mem_photo']);}
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">备注</label>
						<div class="col-sm-8">
							{php echo tpl_ueditor('content', $item['content']);}
							<span class="help-block"></span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label"></label>
						<div class="col-sm-4">
							<input type="hidden" name="token" value="{$_W['token']}" />
							<input name="submit" type="submit" value="提交" class="btn btn-primary span3" />
						</div>
					</div>	
				</div>
			</div>
		</form>
	</div>
	{elseif $op =='display'}
	<div class="panel panel-success">
        <div class="panel-heading">常用工具 > 用户列表</div>
		<div class="panel-body">
			<form role="form" class="form-horizontal" method="get" action="./index.php">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="m" value="tim_welfare" />
				<input type="hidden" name="do" value="phb" />
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">微信昵称</label>
					<div class="col-sm-8">
						<input type="text" class="form-control" id="mem_name" name="mem_name" value="{$mem_name}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">排序</label>
					<div class="col-sm-8">
						<select name="px" id="px" class="form-control">
							<option value="1" {if $px == 1 } selected="selected" {/if}>按加入时间排序</option>
							<option value="2" {if $px == 2 } selected="selected" {/if}>按捐款金额排序</option>
							<option value="3" {if $px == 3 } selected="selected" {/if}>按捐款次数排序</option>
					   </select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
					<div class="col-sm-4">
					   <input id="search" type="submit" value="搜索" class="btn btn-primary span3" /> 
					</div>
				</div>
			</form>
		</div>
	</div>
	<div class="main">
		<form id="form2" class="form-horizontal" method="post">
			<table class="table table-hover">
				<thead class="navbar-inner">
					<tr>
						<th style="text-align:center;">头像</th>
						<th style="text-align:center;">昵称</th>						
	          			<th style="text-align:center;">捐款次数</th>
	          			<th style="text-align:center;">捐款总金额</th>
						<th style="text-align:center;">操作</th>
					</tr>
				</thead>
				<tbody>
					{loop $list $item}
					<tr>
						<td style="text-align:center;">
							{if !empty($item['mem_photo'])}		
								{if !empty($item['openid'])}	
									<img src="{$item['mem_photo']}" style="width:40px;border-radius:50%">
								{else}
									<img src="{php echo tomedia($item['mem_photo']);}" style="width:40px;border-radius:50%">
								{/if}	
							{else}
								<img src="{php echo tomedia($set['gy_logo']);}" style="width:40px;border-radius:50%">
							{/if}
						</td>
						<td style="text-align:center;">
						{if empty($item['content'])}
							<span>{$item['mem_name']}</span>
						{else}
							<span style="color:#0077FF; cursor:pointer;" id="{$item['mem_id']}" onmouseover="ckxq('{$item['content']}','{$item['mem_id']}');">{$item['mem_name']}</span>
						{/if}
						</td>
						<td style="text-align:center;">{$item['count']}</td>
						<td style="text-align:center;"><?php if(empty($item['sum'])){echo 0;}else{echo $item['sum'];}?></td>					
						<td style="text-align:center;">
							<a href="{php echo $this->createWebUrl('phb', array('op' => 'see', 'mem_id' => $item['mem_id']))}" title="捐款明细" class="btn btn-xs btn-primary"><span class="icon icon-compose">捐款明细</span></a>
						</td>				
					</tr>
					{/loop}
				</tbody>
			</table>
			<input type="hidden" name="token" value="{$_W['token']}" />
		</form>
		{$pager}
		<script>	
			function ckxq (content,mem_id){		
				layer.tips(content, '#'+mem_id, {
				  tips: [1, '#3595CC'],
				  time: 4000
				});
			}
		</script>	
	</div>
	{elseif $op == 'see'}
	<div class="panel panel-success">
	  	<div class="panel-heading">常用工具 >捐款明细</div>
	</div>
	<div class="main">
		<form id="form2" class="form-horizontal" action="{php echo $this->createWebUrl('phb', array('op' => 'del'));}" method="post">
			<table class="table table-hover">
				<thead class="navbar-inner">
					<tr>
	          			<th style="width:30px">全选</th>
						<th style="text-align:center;">项目</th>						
	          			<th style="text-align:center;width:80px;">捐款金额</th>
	          			<th style="text-align:center;">订单号</th>
	          			<th style="text-align:center;">捐款时间</th>
						<th style="text-align:center;">操作</th>
					</tr>
				</thead>
				<tbody>
					{loop $list $item}
					<tr>
						<td><input type="checkbox" value="{$item['fund_id']}" name="delete[]"></td>
						<td style="text-align:center;">{$item['pro_name']}</td>
						<td style="text-align:center;">{$item['fund_value']}</td>
						<td style="text-align:center;">{$item['order_num']}</td>
						<td style="text-align:center;">{php echo  date('Y-m-d H:i:s', $item['fund_time']);}</td>	
						<td style="text-align:center;">
							<a onclick="if(confirm('此操作不可恢复，确认吗？')){location.href='{php echo $this->createWebUrl('phb', array('fund_id' => $item['fund_id'],'op'=>'del'))}'}" href="javascript:;" title="删除" class="btn btn-xs btn-danger"><span class="icon icon-close">删除</span></a>	
						</td>				
					</tr>
					{/loop}
					<tr>
						<td><input type="checkbox"  onclick="var ck = this.checked;$(':checkbox').each(function(){this.checked = ck});" name=''>
							<input class="btn btn-primary btn-xs" type="submit" value="删除" name="submit" >
						</td>
						<td></td><td></td><td></td><td></td><td></td><td></td>
					</tr>
				</tbody>
			</table>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-10 control-label"></label>
				<div class="col-sm-2">
					<input type="hidden" name="token" value="{$_W['token']}" />
					<input type="button" value="增加捐款明细" class="btn btn-primary span3" onclick="jkmx('{$mem_id}');"/>
				</div>
			</div>
		</form>
		{$pager}		
		<script>
			$('#form2').submit(function(){
				if($(":checkbox[name='delete[]']:checked").size() > 0){
					return confirm('删除后不可恢复，您确定删除吗？');
				}
				return false;
			}); 

			function jkmx(mem_id) {
	       		layer.open({
				  	type: 2,
				  	title: '捐款明细',
					shadeClose: true,
					offset: '',
					scrollbar : false,
					shade: 0.3,
					maxmin: true, //开启最大化最小化按钮
					area: ['600px', '330'],
				    content: "{php echo $this->createWebUrl('jkmx'); }"+"&mem_id="+mem_id
				});		
			}
		</script>	
	</div>
{/if}		
</div>
{template 'common/footer'}

